Page({
  data: {
    theme: '',
    ysxyzt: true,
    ysxyxs: true,
    xrjtb: false,
    bluetooth: false,
    bluetootha: false
  },
  onShow() {
    var that = this
    that.setData({
      theme: wx.getAppBaseInfo().theme,
      ysxyzt: true,
      ysxyxs: true,
      xrjtb: false,
      bluetooth: false,
      bluetootha: false
    })
    wx.getSetting({
      success(res) {
        let zt = res.authSetting['scope.bluetooth']
        if (zt == true) {
          that.setData({
            bluetooth: true
          })
        }
      }
    })
    if (wx.getStorageSync('qxsetting').lx == 'qx') {
      wx.getStorage({
        key: 'qxsetting',
        success(res) {
          var t = res.data
          that.setData({
            xrjtb: t.xrjtb,
            bluetootha: t.bluetootha
          })
          that.ysxyjc()
        }
      })
      return
    }
    that.ysxyjc()
  },
  ysxyjc() {
    var that = this
    wx.getPrivacySetting({
      success(res) {
        if (res.needAuthorization == true) {
          that.setData({
            bluetooth: false
          })
        }
        if (res.needAuthorization == false) {
          that.setData({
            ysxyzt: false
          })
        }
      }
    })
  },
  complete() {
    this.setData({
      ysxyxs: false
    })
  },
  onUnload() {
    var t = this.data
    wx.setStorage({
      key: 'qxsetting',
      data: {
        lx: 'qx',
        xrjtb: t.xrjtb,
        bluetootha: t.bluetootha
      }
    })
  },
  ysbhzy() {
    var app = getApp()
    if (app.globalData.network == 'none') {
      wx.showToast({
        title: '无网络',
        icon: 'error'
      })
      return
    }
    wx.openPrivacyContract()
  },
  tz() {
    var app = getApp()
    if (app.globalData.network == 'none') {
      wx.showToast({
        title: '无网络',
        icon: 'error'
      })
      return
    }
    wx.openSetting({
      fail() {
        wx.showToast({
          title: '暂不支持',
          icon: 'error'
        })
      }
    })
  },
  xrjtb(e) {
    var a = e.detail.value
    this.setData({
      xrjtb: a
    })
  },
  bluetootha(e) {
    var a = e.detail.value
    this.setData({
      bluetootha: a
    })
  }
})